/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package servidormemory;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import memory.Jugador;
import memory.Puntuacion;

/**
 *
 * @author DAM110
 */
public class AtenderCliente extends Thread{
    
    private Socket cliente;
    private ObjectInputStream in;
    private ObjectOutputStream out;

    public AtenderCliente(Socket cliente) {
        this.cliente = cliente;
    }
    
    @Override
    public void run(){
        try {
            
            
       
            in = new ObjectInputStream(cliente.getInputStream());
            ArrayList<Jugador> leido = (ArrayList<Jugador>)in.readObject();
            Puntuacion p = new Puntuacion();
            p.addAll(leido);
            
            
            GuardarPuntuacion.guardarPuntuacion(p);
            
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(AtenderCliente.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            
            GestionarEstado.setLEstado("Finalizado");
        }
        
    }
}
